# -*- coding: UTF-8 -*-
import numpy as np
from numpy.linalg import inv, det, eig, solve


def startMain():
    list = [[1, 3, 5], [2, 4, 6]]
    print(type(list))
    np_list = np.array(list)
    print(type(np_list))
    nplist = np.array(list, dtype=np.float)
    print(np_list.shape)
    print(np_list.ndim)
    print(np_list.dtype)
    print(np_list.itemsize)
    print(np_list.size)
    print(np.zeros([2, 4]))
    print np.random.randint(2, 4)
    print np.random.rand()
    print "RandInt:"
    print np.random.randint(1, 10, 3)
    print 'Randon:'
    print np.random.randn(2, 4)
    print "chiose:"
    print np.random.choice([10, 20, 30, 2, 8])
    print "Distribute:"
    print np.random.beta(1, 10, 100)

    # array
    print '---第三------'
    llist = np.arange(1, 11).reshape([2, -2])
    print np.exp(llist)
    print np.exp2(llist)
    print np.sqrt(llist)
    print np.sin(llist)
    print np.log(llist)

    lst1=np.array([10,20,30,40])
    lst2=np.array([4,3,2,1])
    print lst1+lst2
    print lst1*lst2
    print np.dot(lst1.reshape([2,2]),lst2.reshape([2,2]))
    print np.concatenate((lst1,lst2),axis=0)
    print np.vstack((lst1,lst2))
    print np.hstack((lst1,lst2))
    print np.split(lst1,2)


def main():
    print "--------第四节---------"
    print np.eye(3)
    lst=np.array([[1.,2.],[3.,4.]])
    print "lnv:"
    print inv(lst)
    print "T:"
    print lst.transpose()
    print "Det:"
    print det(lst)
    print eig(lst)
    y=np.array([[5.],[7.]])
    print solve(lst,y)

def four():
    print "FFT:"
    print np.fft.fft(np.array([1,1,1,1,1,1,1,1]))
    print "coef:"
    print np.corrcoef([1,0,1],[0,2,1])

if __name__ == '__main__':
#startMain()
#main()
    four()
